<template>
    <el-breadcrumb>
        <el-breadcrumb-item :to="{ path: 'home' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>我的选课</el-breadcrumb-item>
    </el-breadcrumb>
  <div class="data">
        <p style="margin-left:10px ;">课程信息</p>
        <el-table :data="tableData" stripe style="width: 100%">
            <el-table-column prop="cname" label="课程名称" width="180" />
            <el-table-column prop="courseid" label="课程编号" width="180" />
            <el-table-column prop="type" label="课程类型" />
            <el-table-column prop="ctime" label="学时" />
            <el-table-column prop="credit" label="学分" />
            <el-table-column prop="teacher" label="授课教师" />
            <el-table-column label="操作" min-width="120" v-if="userstore.userinfo.roleid==1">
                <template #default>
                    <el-button type="primary" size="small">编辑</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
    <el-pagination v-model:current-page="queryinfo.pagenum" v-model:page-size="queryinfo.pagesize"
        :page-sizes="[2,3,4,5]" layout="total, sizes, prev, pager, next, jumper" :total="total"
        @size-change="handleSizeChange" @current-change="handleCurrentChange" />
</template>

<script setup lang='ts'>
import { ref, onMounted } from 'vue'
import { getstucourse } from '@/apis/person';
// @ts-ignore
import { Userstore } from '@/stores/user.js';
const userstore = Userstore()
const tableData = ref([{},])
const queryinfo = ref({
    pagesize: 4,
    pagenum: 1
})
const total = ref(0)
const courselist = async () => {
    const res = await getstucourse({...queryinfo.value,studentid:userstore.userinfo.stuid })
    console.log(res);
    
    tableData.value = res.data.course
    total.value = res.data.total
}
const handleSizeChange = (val: any) => {
    courselist()
}
const handleCurrentChange = (val: any) => {
    courselist()
}
onMounted(() => {
    courselist()
})
</script>
<style lang='scss' scoped></style>